package com.tejava.cafe_in;

import java.net.ContentHandler;
import java.util.ArrayList;

import android.app.Activity;
import android.app.ActivityManager;
import android.app.AlertDialog;
import android.app.ListActivity;
import android.content.Context;
import android.content.DialogInterface;
import android.content.Intent;
import android.os.Bundle;
import android.view.KeyEvent;
import android.view.View;
import android.widget.AdapterView;
import android.widget.AdapterView.OnItemClickListener;
import android.widget.ArrayAdapter;
import android.widget.ListAdapter;
import android.widget.ListView;
import android.widget.TabHost;
import android.widget.Toast;
import android.widget.TabHost.TabSpec;


public class Tab04 extends Activity {
    private ArrayList<String> list;
    private NoticeAdapter adapter;
    private ListView listView;
    private Context mContext;
    
	public void onCreate(Bundle savedInstanceState){
		super.onCreate(savedInstanceState);
		setContentView(R.layout.tab04);
		mContext = this;
		
		list = new ArrayList<String>();
		
		listView = (ListView)findViewById(R.id.tab04_listView);
		
		list.add("공지사항");
		
		list.add("이용안내");
		
		 adapter = new NoticeAdapter(this, 
	        		R.layout.tab04_list, list);
		 
		 
	        
	     listView.setAdapter(adapter);
	     // ColorHint 0
	     listView.setCacheColorHint(0);
	     listView.setOnItemClickListener(itemClickListenerOfLanguageList);
	     
	     
	     





	}
	
	
	
    private OnItemClickListener itemClickListenerOfLanguageList = new OnItemClickListener()
    {
    	
        public void onItemClick(AdapterView<?> adapterView, View clickedView, int position, long id)
        {
        	if(position == 0){
	    		Intent i = new Intent(mContext, Tab04_Notice.class);
	    		startActivity(i);
//				finish();
	    	}
	    	else if(position == 1){
	    		Intent i = new Intent(mContext, Tab04_Guide.class);
				startActivity(i);
//				finish();
	    	}
	    	
        }
    };
	
    
	public boolean onKeyDown(int keyCode, KeyEvent event) {
		if (keyCode == KeyEvent.KEYCODE_BACK) {
			
		
			new AlertDialog.Builder(Tab04.this)
					.setTitle(getResources().getString(R.string.app_name))
					.setMessage("프로그램을 종료하시겠습니까?")
					.setPositiveButton("네",
							new DialogInterface.OnClickListener() {

								@Override
								public void onClick(DialogInterface dialog,
										int which) {
									// TODO Auto-generated method stub
									moveTaskToBack(true);
									finish();
								}
							}).setNegativeButton("아니오", null).show();
		}
		return true;
	}



	/*
	 @Override
	    protected void onListItemClick (ListView l, View v, int position, long id){
	    	super.onListItemClick(l, v, position, id);
	    	//getLocal activity manager 
	    	
	    	if(position == 0){
	    		Intent i = new Intent(this, Tab04_Notice.class);
	    		startActivity(i);
//				finish();
	    	}
	    	else if(position == 1){
	    		Intent i = new Intent(this, Tab04_Setup.class);
				startActivity(i);
//				finish();
	    	}
	    	else if(position == 2){
	    		Intent i = new Intent(this, Tab04_Guide.class);
				startActivity(i);
//				finish();
	    	}
	    	
	    }
	*/
}
